
package org.itver.graphics.guitools;

import org.itver.graphics.controller.TransformGroupManipulator;

/**
 * Clase que se encarga de generar un control integrado a la interfaz gráfica,
 * para realizar diversos movimientos de la cámara.
 *
 * <br/>Tanto esta clase como {@link org.itver.graphics.controller.CameraKeyBehavior}
 * trabajan sobre un objeto de tipo
 * {@link org.itver.graphics.controller.TransformGroupManipulator} con el cual
 * se realizan todas las operaciones de control sobre la cámara o punto de
 * visión del usuario.
 *
 * @author Karo
 */
public class Control extends javax.swing.JPanel {
    TransformGroupManipulator tgm;

    /**
     * Crea una nueva instancia del Control gráfico y recibe un
     * {@link org.itver.graphics.controller.TransformGroupManipulator} para
     * implementar la manipulación de la cámara.
     * @param tgm TransformGroupManipulator de la cámara.
     */
    public Control(TransformGroupManipulator tgm) {
        this.tgm = tgm;
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        stepLeft = new javax.swing.JButton();
        turnRightButton = new javax.swing.JButton();
        goDownButton = new javax.swing.JButton();
        riseUpButton = new javax.swing.JButton();
        turnLeftButton = new javax.swing.JButton();
        stepRight = new javax.swing.JButton();
        stepBackwardButton = new javax.swing.JButton();
        stepForwardButton = new javax.swing.JButton();

        setBackground(new java.awt.Color(255, 255, 255));
        setAlignmentX(0.0010F);
        setAlignmentY(0.0010F);
        setMaximumSize(new java.awt.Dimension(121, 116));
        setMinimumSize(new java.awt.Dimension(121, 116));
        setPreferredSize(new java.awt.Dimension(200, 200));

        jPanel1.setOpaque(false);
        jPanel1.setPreferredSize(new java.awt.Dimension(140, 140));
        jPanel1.setLayout(null);

        stepLeft.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/itver/graphics/guitools/img/leftt2.png"))); // NOI18N
        stepLeft.setToolTipText("Step leftward (Q)");
        stepLeft.setBorderPainted(false);
        stepLeft.setContentAreaFilled(false);
        stepLeft.setMargin(new java.awt.Insets(0, 0, 0, 0));
        stepLeft.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/org/itver/graphics/guitools/img/leftt2H.png"))); // NOI18N
        stepLeft.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                stepLeftActionPerformed(evt);
            }
        });
        jPanel1.add(stepLeft);
        stepLeft.setBounds(50, 55, 20, 20);

        turnRightButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/itver/graphics/guitools/img/rightt.png"))); // NOI18N
        turnRightButton.setToolTipText("Turn right (D)");
        turnRightButton.setBorderPainted(false);
        turnRightButton.setContentAreaFilled(false);
        turnRightButton.setMaximumSize(new java.awt.Dimension(33, 84));
        turnRightButton.setMinimumSize(new java.awt.Dimension(33, 84));
        turnRightButton.setPreferredSize(new java.awt.Dimension(133, 184));
        turnRightButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/org/itver/graphics/guitools/img/righttH.png"))); // NOI18N
        turnRightButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                turnRightButtonActionPerformed(evt);
            }
        });
        jPanel1.add(turnRightButton);
        turnRightButton.setBounds(97, 20, 40, 90);

        goDownButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/itver/graphics/guitools/img/down.png"))); // NOI18N
        goDownButton.setToolTipText("Go down (X)");
        goDownButton.setBorderPainted(false);
        goDownButton.setContentAreaFilled(false);
        goDownButton.setPreferredSize(new java.awt.Dimension(83, 34));
        goDownButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/org/itver/graphics/guitools/img/downH.png"))); // NOI18N
        goDownButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                goDownButtonActionPerformed(evt);
            }
        });
        jPanel1.add(goDownButton);
        goDownButton.setBounds(29, 89, 90, 40);

        riseUpButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/itver/graphics/guitools/img/up.png"))); // NOI18N
        riseUpButton.setToolTipText("Up (Space Bar)");
        riseUpButton.setBorderPainted(false);
        riseUpButton.setContentAreaFilled(false);
        riseUpButton.setPreferredSize(new java.awt.Dimension(83, 34));
        riseUpButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/org/itver/graphics/guitools/img/upH.png"))); // NOI18N
        riseUpButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                riseUpButtonActionPerformed(evt);
            }
        });
        jPanel1.add(riseUpButton);
        riseUpButton.setBounds(30, 4, 90, 34);

        turnLeftButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/itver/graphics/guitools/img/left.png"))); // NOI18N
        turnLeftButton.setToolTipText("Turn left (A)");
        turnLeftButton.setBorderPainted(false);
        turnLeftButton.setContentAreaFilled(false);
        turnLeftButton.setPreferredSize(new java.awt.Dimension(33, 81));
        turnLeftButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/org/itver/graphics/guitools/img/leftH.png"))); // NOI18N
        turnLeftButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                turnLeftButtonActionPerformed(evt);
            }
        });
        jPanel1.add(turnLeftButton);
        turnLeftButton.setBounds(12, 20, 40, 90);

        stepRight.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/itver/graphics/guitools/img/rightt2.png"))); // NOI18N
        stepRight.setToolTipText("Step Rightward (E)");
        stepRight.setBorderPainted(false);
        stepRight.setContentAreaFilled(false);
        stepRight.setMargin(new java.awt.Insets(0, 0, 0, 0));
        stepRight.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/org/itver/graphics/guitools/img/right2.png"))); // NOI18N
        stepRight.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/org/itver/graphics/guitools/img/right2.png"))); // NOI18N
        stepRight.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                stepRightActionPerformed(evt);
            }
        });
        jPanel1.add(stepRight);
        stepRight.setBounds(80, 55, 20, 20);

        stepBackwardButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/itver/graphics/guitools/img/down2.png"))); // NOI18N
        stepBackwardButton.setToolTipText("Step Backward (S)");
        stepBackwardButton.setBorderPainted(false);
        stepBackwardButton.setContentAreaFilled(false);
        stepBackwardButton.setMargin(new java.awt.Insets(0, 0, 0, 0));
        stepBackwardButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/org/itver/graphics/guitools/img/down2H.png"))); // NOI18N
        stepBackwardButton.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/org/itver/graphics/guitools/img/down2H.png"))); // NOI18N
        stepBackwardButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                stepBackwardButtonActionPerformed(evt);
            }
        });
        jPanel1.add(stepBackwardButton);
        stepBackwardButton.setBounds(65, 70, 20, 20);

        stepForwardButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/itver/graphics/guitools/img/up2.png"))); // NOI18N
        stepForwardButton.setToolTipText("Step Forward (W)");
        stepForwardButton.setBorderPainted(false);
        stepForwardButton.setContentAreaFilled(false);
        stepForwardButton.setMargin(new java.awt.Insets(0, 0, 0, 0));
        stepForwardButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/org/itver/graphics/guitools/img/up2H.png"))); // NOI18N
        stepForwardButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                stepForwardButtonActionPerformed(evt);
            }
        });
        jPanel1.add(stepForwardButton);
        stepForwardButton.setBounds(65, 40, 20, 20);

        add(jPanel1);
    }// </editor-fold>//GEN-END:initComponents

    /**
     * Paso adelante.
     * @param evt Evento.
     */
    private void stepForwardButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stepForwardButtonActionPerformed
        tgm.stepForward();
}//GEN-LAST:event_stepForwardButtonActionPerformed

    /**
     * Paso atrás.
     * @param evt Evento.
     */
    private void stepBackwardButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stepBackwardButtonActionPerformed
        tgm.stepBackward();
}//GEN-LAST:event_stepBackwardButtonActionPerformed

    /**
     * Paso a la derecha.
     * @param evt Evento.
     */
    private void stepRightActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stepRightActionPerformed
        tgm.stepRightward();
}//GEN-LAST:event_stepRightActionPerformed

    /**
     * Paso a la izquierda.
     * @param evt Evento.
     */
    private void turnLeftButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_turnLeftButtonActionPerformed
        tgm.turnLeft();
}//GEN-LAST:event_turnLeftButtonActionPerformed

    /**
     * Subir.
     * @param evt Evento.
     */
    private void riseUpButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_riseUpButtonActionPerformed
        tgm.riseUp();
}//GEN-LAST:event_riseUpButtonActionPerformed

    /**
     * Bajar.
     * @param evt Evento.
     */
    private void goDownButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_goDownButtonActionPerformed
        tgm.goDown();
}//GEN-LAST:event_goDownButtonActionPerformed

    /**
     * Girar a la derecha.
     * @param evt Evento.
     */
    private void turnRightButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_turnRightButtonActionPerformed
        tgm.turnRight();
}//GEN-LAST:event_turnRightButtonActionPerformed

    /**
     * Girar a la izquierda.
     * @param evt Evento.
     */
    private void stepLeftActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stepLeftActionPerformed
        tgm.stepLeftward();
}//GEN-LAST:event_stepLeftActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton goDownButton;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JButton riseUpButton;
    private javax.swing.JButton stepBackwardButton;
    private javax.swing.JButton stepForwardButton;
    private javax.swing.JButton stepLeft;
    private javax.swing.JButton stepRight;
    private javax.swing.JButton turnLeftButton;
    private javax.swing.JButton turnRightButton;
    // End of variables declaration//GEN-END:variables

}
